﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Idlesoft.Utils
{
	public static class LogExtensions
	{
		#region log
		public static Exception Log(this Exception ex)
		{
			LogHelper.Log(ex.Expand());
			return ex;
		}
		public static TItem Log<TItem>(this TItem item)
		{
			LogHelper.Log(item);
			return item;
		}
		public static TItem Log<TItem>(this TItem item, params object[] args)
		{
			LogHelper.Log(item.ToString() + args.Flatten(" ", " ", " "));
			return item;
		}
		public static IEnumerable<TItem> Log<TItem>(this IEnumerable<TItem> items)
		{
			items.ForEach(i => i.Log());
			return items;
		}
		public static TItem[] Debug<TItem>(this TItem[] items)
		{
			items.ForEach(i => i.Log());
			return items;
		}
		public static List<TItem> Debug<TItem>(this List<TItem> items)
		{
			items.ForEach(i => i.Log());
			return items;
		}
		public static string Log(this string format, params object[] args)
		{
			LogHelper.Log(format, args);
			return format;
		}
		public static IEnumerable<string> Log(this IEnumerable<string> formats, params object[] args)
		{
			formats.ForEach(f => f.Log(args));
			return formats;
		}
		public static string[] Log(this string[] formats, params object[] args)
		{
			formats.ForEach(f => f.Log(args));
			return formats;
		}
		public static List<string> Log(this List<string> formats, params object[] args)
		{
			formats.ForEach(f => f.Log(args));
			return formats;
		}
		#endregion log
	}
}
